<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改批量条形码')"/>
    <th:block th:include="include :: datetimepicker-css"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-tag-edit" th:object="${yfTag}">

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">编码ID：</label>
            <div class="col-sm-8">
                <input name="codeid" id="codeid" class="form-control" type="text" readonly th:field="*{codeid}"
                       required>
            </div>
        </div>


        <!-- WM(Waiting  modify)：修改为树装选择图-->
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label is-required">暂存点：</label>
            <div class="col-sm-8">
                <select name="stagingId" id="stagingId" class="form-control m-b" readonly
                        th:with="type=${@dep.depts(null,'400,310,360,370')}" th:field="*{stagingId}"
                        required>
                    <option value="">请选择</option>
                    <option th:each="dep : ${type}" th:text="${dep.deptName}" th:value="${dep.deptId}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">医废类别：</label>
            <div class="col-sm-8">
                <select name="trashType" class="form-control m-b" th:with="type=${@dict.getType('yf_trash_type')}"
                        required>
                    <option th:field="*{trashType}" th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">重量(kg)：</label>
            <div class="col-sm-8">
                <input name="weight" th:field="*{weight}" class="form-control" type="number" required min="0.01" max="100000">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">数量(袋)：</label>
            <div class="col-sm-8">
                <input name="bag" th:field="*{bag}" class="form-control" type="number" required max="1000" min="1">
            </div>
        </div>


        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label is-required">入库用户：</label>
            <div class="col-sm-8">
                <select name="intoUserId" id="intoUserId" class="form-control m-b" required>
                    <option value="">请选择用户</option>
                    <option th:field="*{intoUserId}" th:each="v :${userList}" th:text="${v.userName}"
                            th:value="${v.userId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label ">入库时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="intoDate" th:value="${#dates.format(yfTag.intoDate, 'yyyy-MM-dd HH:mm:ss')}"
                           class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text">
                </div>
            </div>
        </div>
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label is-required">出库用户：</label>
            <div class="col-sm-8">
                <select name="outUserId" id="outUserId" class="form-control m-b" required>
                    <option value="">请选择用户</option>
                    <option th:field="*{outUserId}" th:each="v :${userList}" th:text="${v.userName}"
                            th:value="${v.userId}"></option>
                </select>
            </div>
        </div>

        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label ">出库时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="outDate" th:value="${#dates.format(yfTag.outDate, 'yyyy-MM-dd HH:mm:ss')}"
                           class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text">
                </div>
            </div>
        </div>


        <!-- 状态 -->
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label is-required">出入库状态 ：</label>
            <div class="col-sm-8">
                <select name="trashStatus" class="form-control m-b" th:with="type=${@dict.getType('yf_trash_status')}"
                        required>
                    <option th:each="dict : ${type}" th:field="*{trashStatus}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <!-- 动态 -->
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <select name="status" class="form-control m-b"
                        th:field="*{status}">
                    <option th:each="dict : ${@dict.getType('yf_exception_status')}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label">删除状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('del_flag')}">
                    <input type="radio" th:id="${'delFlag_' + dict.dictCode}" name="delFlag" th:field="*{delFlag}"
                           th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${'delFlag_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>

        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label is-required">更新方式：</label>
            <div class="col-sm-8">
                <select name="updateWay" th:field="*{updateWay}" class="form-control m-b"
                        th:with="type=${@dict.getType('yf_update_way')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                            th:selected="${dict.isDefault=='Y'}"></option>
                </select>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "yf/tag";

    $("input[name='collectScanDate']").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    $("input[name='scanDeptDate']").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    $("input[name='collectUpdateDate']").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    $("input[name='intoDate']").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    $("input[name='outDate']").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    // var yfTag =  [  [${yfTag}]  ];
    //获取用户
    function getUser(stagingId, roleId) {
        $.post(ctx + "system/user/adds/list", {
            stagingId: stagingId
        }, function (res) {
            if (res.code == 0) {
                console.log(res)
                var html = "<option value='0'>请选择</option>";
                $.each(res.rows, function (i, v) {
                    html += ' <option  value="' + v.userId + '" >' + v.userName + '</option>';
                })
                if (html != "") {
                    //采集员
                    $("#collectUserId").html(html)
                    $("#collectUserId").attr("disabled", false);
                    //入库员
                    $("#intoUserId").html(html)
                    $("#intoUserId").attr("disabled", false);
                    //出库员
                    $("#outUserId").html(html)
                    $("#outUserId").attr("disabled", false);
                } else {
                    //采集员
                    $("#collectUserId").html('<option value="" >请选择</option>')
                    $("#collectUserId").attr("disabled", true);
                    //入库员
                    $("#intoUserId").html('<option value="" >请选择</option>')
                    $("#intoUserId").attr("disabled", true);
                    //出库员
                    $("#outUserId").html('<option value="" >请选择</option>')
                    $("#outUserId").attr("disabled", true);
                }
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-tag-edit').serialize());
        }
    }

    $("#form-tag-edit").validate({
        focusCleanup: true,
        rules: {
            weight: {
                required: true,
                is_double: true
            },
            bag:{
                required: true,
                is_int: true
            }
        },
        message: {
        }
    });

    $.validator.addMethod("is_double", function (value, element, params) {
        var double = /^[0-9]+(\.[0-9]{0,2})?$/;
        return this.optional(element) || (double.test(value));
    }, "请输入数字，仅限2位小数！");

    $.validator.addMethod("is_int", function (value, element, params) {
        var districts = /^[1-9]\d{0,5}$/gm;
        return this.optional(element) || (districts.test(value));
    }, "*请输入整数！");

    $("input[name='collectScanDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='scanDeptDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='collectUpdateDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='intoDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='outDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>